<?php
/*
* $Author ：PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2018 宿迁鑫潮信息技术有限公司，并保留所有权利。
*
* 软件声明：未经授权前提下，不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class job_controller extends wxapp_controller{
	function list_action(){//职位列表
		$where = "`r_status`<>'2' and `status`<>'1' and `state`=1";
		$provinceid=(int)$_POST['provinceid'];
		$cityid=(int)$_POST['cityid'];
		$three_cityid=(int)$_POST['three_cityid'];
		$job1=(int)$_POST['job1'];
		$job1_son=(int)$_POST['job1_son'];
		$job_post=(int)$_POST['job_post'];
		$exp=(int)$_POST['exp'];
		$hy=(int)$_POST['hy'];
		$pr=(int)$_POST['pr'];
		$mun=(int)$_POST['mun'];
		$edu=$_POST['edu'];
		
		$jobid=$_POST['jobid'];
		$sdate=$_POST['sdate'];
		$edate=$_POST['edate'];
		if ($_POST['keyword']!='undefined'){
		    $keyword=$this->stringfilter($_POST['keyword']);
		}
		$order=$_POST['order'];
		$nodata=$_POST['nodata'];
		$uid=(int)$_POST['uid'];
		$state=(int)$_POST['state'];
		$rec = (int)$_POST['rec'];
		
		if($_POST['state']){
			if($_POST['state']==2){
				$where.=" and `edate`<'".time()."'";
			}elseif($_POST['state']==4){
				$where.=" and `state`='0'";
			}else{
				$where.=" and `state`='".$_POST['state']."'";
			}
		}
		if($edu){
			$where.=" and `edu`='".$edu."'";
		}
		if($_POST['r_status']){
			$where.=" and `r_status`='".(int)$_POST['r_status']."'";
		}
		if($_POST['status']){
			$where.=" and `status`='".(int)$_POST['status']."'";
		}
		if($rec==1){
		    $recRating = array();
		    include PLUS_PATH."/comrating.cache.php";
		    if($comrat){
		        foreach($comrat as $value){
		            if($value['display']=='1' && $value['category']=='1' && $value['jobrec']=='2'){
						$recRating[] = $value['id'];
					}
				}
			}
			if(!empty($recRating)){
				$recRaringId = implode(',',$recRating);
		    
				$where.=" and (`rating` IN (".$recRaringId.") OR `rec_time`>=".time().")";
		    
			}else{
				$where.=" and `rec_time`>=".time();
			}
		}
		if($hy){//类别ID
			$where.=" and `hy`='".$hy."'";
		}
		if($pr){//类别ID
			$where.=" and `pr`='".$pr."'";
		}
		if($mun){//类别ID
			$where.=" and `mun`='".$mun."'";
		}
		if($exp){
			$where.=" and `exp`='".$exp."'";
		}
		if($provinceid){//类别ID
			$where.=" and `provinceid`='".$provinceid."'";
		}
		if($cityid){//类别ID
			$where.=" and `cityid`='".$cityid."'";
		}
		if($jobid){//其他职位
			$where.=" and `id`<>'".$jobid."'";
		}
		if($three_cityid){//类别ID
			$where.=" and `three_cityid`='".$three_cityid."'";
		}
		if($job1){//类别ID
			$where.=" and `job1`='".$job1."'";
		}
		if($job1_son){//类别ID
			$where.=" and `job1_son`='".$job1_son."'";
		}
		if($job_post){//类别ID
			$where.=" and `job_post`='".$job_post."'";
		}
		if($sdate){//开始时间
			$where.=" and `lastupdate`>'".strtotime($sdate)."'";
		}
		if($edate){//结束时间
			$where.=" and `lastupdate`<'".strtotime($edate)."'";
		}
		if($keyword){//关键字
			$where1[]="`name` LIKE '%".$keyword."%'";
			$where1[]="`com_name` LIKE '%".$keyword."%'";
			include(PLUS_PATH."city.cache.php");
			$cityid=array();
			foreach($city_name as $k=>$v){
				if(strpos($v,$keyword)!==false){
					$cityid[]=$k;
				}
			}
			if(!empty($cityid)){
				foreach($cityid as $value){
					$class[]= "(provinceid = '".$value."' or cityid = '".$value."')";
				}
				$where1[]=@implode(" or ",$class);
			}
			$where.=" AND (".@implode(" or ",$where1).")";
		}
		if($uid){//UID
			$where.=" and `uid`='".$uid."'";
		}
		if($nodata){//排除没有值的字段
			$nodataarr=explode(",",$nodata);
			foreach($nodataarr as $v){
				$where.=" and ".$v."<>''";
			}
		}
		$page=$_POST['page'];
		if ($page==1 && !$_POST['place']){
		    if ($this->config['joblist_top']==1){
		        $xswhere = $where." and `xsdate`>'".time()."' order by `lastupdate` asc limit 5";
		        $xsrows = $this->obj->DB_select_all("company_job",$xswhere);
		    }else{
		        $xswhere = $where." and `xsdate`>'".time()."' ORDER BY rand() limit 5";
		        $xsrows = $this->obj->DB_select_all("company_job",$xswhere);
		    }
		}
		if($order){//排序
			$where.=" order by ".$order;
		}else{
			$where.=" order by `lastupdate` desc";
		}
		if ($_POST['limit']){
		    $limit=$_POST['limit'];
		    if($page){//分页
		        $pagenav=($page-1)*$limit;
		        $where.=" limit $pagenav,$limit";
		    }else{
		        $where.=" limit $limit";
		    }
		}
		$rows=$this->obj->DB_select_all("company_job",$where);
		if(is_array($rows)&&$rows){
		    $uids=array();
		    $jobids=array();
		    foreach($rows as $key=>$va){
		        $uids[]=$va['uid'];
		    }
		    if ($xsrows){
		        foreach($rows as $k=>$v){
		            foreach ($xsrows as $val){
		                if($v['id']==$val['id']){
		                    unset($rows[$k]);
		                }
		            }
		        }
		        foreach ($xsrows as $v){
		            array_unshift($rows,$v);
		        }
		    }
		    include PLUS_PATH."city.cache.php";
		    include PLUS_PATH."com.cache.php";
		    $beginToday=strtotime('today');//今天开始时间戳
		    $beginYesterday=strtotime('yesterday');//昨天开始时间戳
		    $week=strtotime("-1 week",time());//一周内时间戳
			$uids=array();
			$jobids=array();
			foreach($rows as $key=>$va){
			    $uids[]=$va['uid'];
			    $jobids[]=$va['id'];
				$list[$key]['id']		=$va['id'];
				$list[$key]['name']		=mb_substr($va['name'], 0,16,'utf-8');
				$list[$key]['comid']	=$va['uid'];
				
				$list[$key]['comname']	=mb_substr($va['com_name'], 0,20,'utf-8');//公司名称com_name
				$list[$key]['hy']		=$va['hy'];
				$list[$key]['job1']		=$va['job1'];
				$list[$key]['job1_son']	=$va['job1_son'];
				$list[$key]['job_post']	=$va['job_post'];
				$list[$key]['exp']		=$va['exp'];
				$list[$key]['edu']		=$va['edu'];
				$list[$key]['lastupdate']=$va['lastupdate'];
				$list[$key]['provinceid']=$va['provinceid'];
				$list[$key]['cityid']	=$va['cityid'];
				$list[$key]['three_cityid']=$va['three_cityid'];
				$list[$key]['minsalary']	=$va['minsalary'];
				$list[$key]['maxsalary']	=$va['maxsalary'];
				$list[$key]['number']	=$va['number'];
				$list[$key]['report']	=$va['report'];
				$list[$key]['state']	=$va['state'];
				$list[$key]['sex']		=$va['sex'];
				$list[$key]['marriage']	=$va['marriage'];
				$list[$key]['xuanshang']=$va['xuanshang'];
				$list[$key]['sdate']	=$va['sdate'];
				$list[$key]['edate']	=$va['edate'];
				$list[$key]['jobhits']	=$va['jobhits'];
				$list[$key]['rec']		=$va['rec'];
				$list[$key]['cloudtype']=$va['cloudtype'];
				$list[$key]['statusbody']=$va['statusbody'];
				$list[$key]['age']		=$va['age'];
				$list[$key]['urgent_time']	=$va['urgent_time'];
				$list[$key]['rec_time']	=$va['rec_time'];
				//小程序所需汉字字段-start
				$list[$key]['city']     =$city_name[$va['cityid']]?$city_name[$va['provinceid']].'-'.$city_name[$va['cityid']]:$city_name[$va['provinceid']];
				if ($va['minsalary']){
				    if ($va['maxsalary']>0){
				        $list[$key]['salary_n']=$va['minsalary'].'-'.$va['maxsalary'];
				    }else{
				        $list[$key]['salary_n']=$va['minsalary'].'以上';
				    }
				}else{
				    $list[$key]['salary_n']='面议';
				}
				$list[$key]['exp_n']    =$comclass_name[$va['exp']];
				$list[$key]['edu_n']    =$comclass_name[$va['edu']];
				if ($va['lastupdate']>$week && $va['lastupdate']<$beginYesterday){
				    $list[$key]['lastupdate_n']="一周内";
				}elseif($va['lastupdate']>$beginYesterday && $va['lastupdate']<$beginToday){
				    $list[$key]['lastupdate_n']="昨天";
				}elseif($va['lastupdate']>$beginToday){
					$list[$key]['lastupdate_n'] = date("H:i",$va['lastupdate']);
				}else{
					$list[$key]['lastupdate_n'] = date("Y-m-d",$va['lastupdate']);
				}
				
				if($va['rec_time']>time()){
				    $list[$key]['rec_n']=1;
				}
				if($va['xsdate']>$time){
				    $list[$key]['isxs']	=1;
				}
                //小程序所需汉字字段-end
			}
			$com_rows=$this->obj->DB_select_all("company","`uid` in (".pylode(',',$uids).")","`uid`,`shortname`,`address`,`welfare`");
			$userid_job=$this->obj->DB_select_all("userid_job","`job_id` in (".pylode(',',$jobids).") group by `job_id`","count(`id`) as num,`job_id`");
			foreach($rows as $key=>$va){
				$list[$key]['userid_job']=0;
				foreach($com_rows as $comKey=>$comVal){
					if($va['uid']==$comVal['uid']){
						$list[$key]['address']=$comVal['address'];
						if($comVal['shortname']){
							$list[$key]['comname']=$comVal['shortname'];
						}
						//获得福利待遇名称
						if($comVal['welfare']){
						    $welfare = @explode(",",$comVal['welfare']);
						    foreach ($welfare as $wk=>$wv){
						        if($wv == '请选择'){
						            unset($welfare[$wk]);
						        }
						    }
						    if (count($welfare)>0){
						        $list[$key]['welfare_n']=$welfare;
						    }
						}
					}
				}
				foreach($userid_job as $v){
					if($va['id']==$v['job_id']){
						$list[$key]['userid_job']=$v['num'];
					}
				}
			}

			if(isset($_POST['muid'])){
				$fav_rows=$this->obj->DB_select_all("fav_job","`uid` in (".$_POST['muid'].") and `job_id` in (".pylode(',',$jobids).")","`job_id`,`uid`,`com_id`");
				foreach($rows as $key=>$va){
					$list[$key]['is_fav']="2";
					foreach($fav_rows as $comKey=>$comVal){
						if($va['id']==$comVal['job_id']){
							$list[$key]['is_fav']="1";
						}
					}
				}
			}
			foreach($list as $k=>$v){
				if(is_array($v)){
					foreach($v as $key=>$val){
						$list[$k][$key]=isset($val)?$val:'';
					}
				}else{
					$list[$k]=isset($v)?$v:'';
				}
			}
			$data['list']=count($list)?$list:array();
			$data['error']=1;
		}else{
			$data['error']=2;
		}
		echo json_encode($data);die;
	}

	function show_action(){//职位内容页
		$id=(int)$_POST['id'];
		$uid=(int)$_POST['uid'];
		$usertype=(int)$_POST['usertype'];
		if(!$id){
			$data['error']=3;
			echo json_encode($data);die;
		}
		$row=$this->obj->DB_select_once("company_job","`id`='".$id."'");
		if($row && is_array($row)){
			$com=$this->obj->DB_select_once("company","`uid`='".$row['uid']."'");
			if($this->config['sy_job_hits']>100 || !$this->config['sy_job_hits']){
			    $this->config['sy_job_hits']=1;
			}
			$hits=rand(1,$this->config['sy_job_hits']);
			$JobM=$this->MODEL('job');
			$JobM->UpdateComjob(array("`jobhits`=`jobhits`+".$hits),array("id"=>$id));
			//职位浏览记录
			$list=array();

			if($usertype=="1"){
				$look_job=$this->obj->DB_select_once("look_job","`uid`='".$uid."' and `jobid`='".$id."'");
				if(!empty($look_job)){
					$this->obj->DB_update_all("look_job","`datetime`='".time()."'","`uid`='".$uid."' and `jobid`='".$id."'");
				}else{
					$value.="`uid`='".$uid."',";
					$value.="`jobid`='".$id."',";
					$value.="`com_id`='".$row['uid']."',";
					$value.="`datetime`='".time()."'";
					$this->obj->DB_insert_once("look_job",$value);
				}
				$useridjob=$this->obj->DB_select_once("userid_job","`uid`='".$uid."' and `job_id`='".$id."'");
				if($useridjob['id']){
					$list['useridjob']=1;
				}else{
					$list['useridjob']=0;
				}
			 
				$favjob=$this->obj->DB_select_once("fav_job","`uid`='".$uid."' and `job_id`='".$id."' and `type`='1' "); 
				if($favjob['id']){
					$list['favjob']=1;
				}else{
					$list['favjob']=0;
				}
			}
			include PLUS_PATH."/city.cache.php";
		    include PLUS_PATH."/com.cache.php";
			include PLUS_PATH."/industry.cache.php";
			include(CONFIG_PATH."db.data.php");	
			$list['id']		   =$row['id'];
			$list['name']	   =mb_substr($row['name'], 0,16,'utf-8');
			$list['comid']	   =$row['uid'];
			if($com['shortname']){
				$list['comname']   =mb_substr($com['shortname'], 0,20,'utf-8');//公司名称com_name
			}else{
				$list['comname']   =mb_substr($row['com_name'], 0,20,'utf-8');//公司名称com_name
			}
			$description = preg_replace("/<([a-zA-Z] )[^>]*>/","<$1>",$row['description']);
			$description=$this->preghtml($description);
			$description = str_replace('<img','<p style="text-align:center;"><img',$description);
			$description=htmlspecialchars_decode($description);
			preg_match_all('<img(.*?)src=\"(.+?)\".*?>',$description,$res);
			if(!empty($res[2])){
			    foreach($res[2] as $v){
			        if(strpos($v,'https:')===false && strpos($v,'http:')===false){
			            $imgurl=$v;
			            $description=str_replace($v,$this->config['sy_weburl'].$imgurl,$description);
			        }
			    }
			}
		    $description=str_replace("<>","",$description);
			$list['pr']		   =$row['pr'];
			$list['mun']	   =$row['mun'];
			$list['hy']		   =$row['hy'];
			$list['job1']	   =$row['job1'];
			$list['job1_son']  =$row['job1_son'];
			$list['job_post']  =$row['job_post'];
			$list['provinceid']=$row['provinceid'];
			$list['cityid']	   =$row['cityid'];
			$list['three_cityid']=$row['three_cityid'];
			$list['minsalary'] =$row['minsalary'];
			$list['maxsalary'] =$row['maxsalary'];
			$list['number']	   =$row['number'];
			$list['exp']	   =$row['exp'];
			$list['edu']	   =$row['edu'];
			$list['report']	   =$row['report'];
			$list['sex']	   =$row['sex'];
			$list['marriage']  =$row['marriage'];
			$list['lastupdate']=$row['lastupdate'];
			$list['age']	   =$row['age'];
			$list['lang']      =$row['lang']?$row['lang']:'';
			$list['welfare']   =$row['welfare']?$row['welfare']:'';
			$list['state']	   =$row['state'];
			$list['description']=str_replace(array("/\r\n\r\n\r\n/","&nbsp;"), array("\r\n",""),$description);
			$list['xuanshang'] =$row['xuanshang'];
			$list['sdate']	   =$row['sdate'];
			$list['edate']	   =$row['edate'];
			$list['jobhits']   =$row['jobhits'];
			$list['rec']	   =$row['rec'];
			$list['cloudtype'] =$row['cloudtype'];
			$list['statusbody']=$row['statusbody'];
			$list['is_link']   =$row['is_link'];
			$list['com_login_link']=$this->config['com_login_link'];
			//查询简历数量
			$ResumeM=$this->MODEL('resume');
			$rnum=$ResumeM->GetResumeExpectNum(array("uid"=>$uid));
			$list['rnum']=$rnum;
			if($uid!=$row['uid']){
			    if($this->config['com_login_link']=="1"){
			        if($row['is_link']!='1'){
			            $look_msg=4;//企业未开放
			        }else{
			            $look_msg=0;//直接查看
			        }
			    }elseif($this->config['com_login_link']=="2"){
			        $look_msg=4;//网站未开放
			    }elseif($uid==''){
			        $look_msg=1;//未登录
			    }if($usertype!="1"){
			        $look_msg=2;//您不是个人用户，不能查看联系方式！
			    }elseif($this->config['com_login_link']=="3"){
			        $look_msg=0;//个人登录直接查看
			    }elseif($this->config['com_login_link']=="4"){
			        if($rnum<1){
			            $look_msg=3; //没有简历
			        }else{
			            $look_msg=0;
			        }
			    }elseif($this->config['com_login_link']=="5"){
			        $sendresume=$this->obj->DB_select_num("userid_job","`uid`='".$uid."' and `job_id`='".$id."'");
			        if($sendresume<1){
			            $look_msg=5; //未投递
			        }else{
			            $look_msg=0;
			        }
			    }
			}else{
			    $look_msg=0;//直接查看
			}
			if($row['is_link']=="1"){
			    if($row['link_type']==1){
			        if (CheckMoblie($com['linktel'])){
			            if($look_msg==1){
			                $list['linktel']=substr_replace($com['linktel'],'****',4,4);
			            }else{
			                $list['linktel']=$com['linktel'];
			            }
			        }
			        $list['linkman']=$com['linkman'];
			    }else{
			        $link=$this->obj->DB_select_once("company_job_link","`jobid`='".$row['id']."'");
			        if ($link){
			            $list['linkman']=$link['link_man'];
			            if($look_msg==1){
			                $list['linktel']=substr_replace($link['link_moblie'],'****',4,4);
			            }else{
			                $list['linktel']=$link['link_moblie'];
			            }
			        }
			    }
			}else{
			    $look_msg=4;
			}
			$list['look_msg']   =$look_msg;
			$list['address']    =$com['address'];
			$list['linkphone']  =$com['linkphone'];
			$list['busstops']   =$com['busstops'];
			//小程序所需汉字字段-start
            $list['city']     =$city_name[$row['cityid']]?$city_name[$row['provinceid']].'/'.$city_name[$row['cityid']]:$city_name[$row['provinceid']];
			$list['pr_n']    =$comclass_name[$row['pr']];
			$list['mun_n']   =$comclass_name[$row['mun']];
			$list['hy_n']    =$industry_name[$row['hy']];
			$list['number_n']=$comclass_name[$row['number']];
			$list['exp_n']   =$comclass_name[$row['exp']];
			$list['edu_n']   =$comclass_name[$row['edu']];
			$list['report_n']=$comclass_name[$row['report']];
			$list['sex_n']   =$arr_data['sex'][$row['sex']];
			$list['marriage_n']=$comclass_name[$row['marriage']];
			$list['age_n']   =$comclass_name[$row['age']];
			if ($row['minsalary']){
				if ($row['maxsalary']>0){
					$list['salary_n']=$row['minsalary'].'-'.$row['maxsalary'];
				}else{
					$list['salary_n']=$row['minsalary'].'以上';
				}
			}else{
				$list['salary_n']='面议';
			}
			$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));//今天开始时间戳
		    $beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));//昨天开始时间戳
		    $week=strtotime(date("Y-m-d",strtotime("-1 week")));//一周内时间戳
			if ($row['lastupdate']>$week && $row['lastupdate']<$beginYesterday){
				$list['lastupdate_n']="一周内";
			}elseif($row['lastupdate']>$beginYesterday && $row['lastupdate']<$beginToday){
				$list['lastupdate_n']="昨天";
			}elseif($row['lastupdate']>$beginToday){
				$list['lastupdate_n'] = date("H:i",$row['lastupdate']);
			}else{
				$list['lastupdate_n'] = date("Y-m-d",$row['lastupdate']);
			}
			if($row['lang']){
				$lang=@explode(',', $row['lang']);
				foreach($lang as $val){
					$list['lang_n'][]=$comclass_name[$val];
				}
			}
			if($row['welfare']){
				$welfare=@explode(',', $row['welfare']);
				foreach($welfare as $val){
				    if ($comclass_name[$val]){
				        $list['welfare_n'][]=$comclass_name[$val];
				    }
				}
			}
			//海报判断
			$list['hbshow']=2;
// 			if($this->config["sy_haibaouser"] && $this->config["sy_haibaopw"] && $this->config["sy_haibaokey"] && $this->config['sy_haibao_isopen']=='1'){
// 			    $list['hbshow']=1;
// 			}
			//小程序所需汉字字段-end
			foreach($list as $k=>$v){
				if(is_array($v)){
					foreach($v as $key=>$val){
						$list[$k][$key]=isset($val)?$val:'';
					}
				}else{
					$list[$k]=isset($v)?$v:'';
				}
			}
			$data['list']=count($list)?$list:array();
			$data['error']=1;
		}else{
			$data['error']=2;
		}
		echo json_encode($data);die;
	}

	function apply_action(){//申请职位
		if(!$_POST['jobid']||!$_POST['uid']){
		    $this->errjson('参数不正确',3);
		}
		$jobid=(int)$_POST['jobid'];
		$uid=(int)$_POST['uid'];
		$UserinfoM=$this->MODEL('userinfo');
		$user=$UserinfoM->GetMemberOne(array('uid'=>$uid),array('field'=>'`usertype`'));
		if($user && $user['usertype']!="1"){
		    $this->errjson('您不是个人用户',6);
		}
		$JobM=$this->MODEL('job');
		$userid_job=$JobM->GetUserJobNum(array('uid'=>$uid,'job_id'=>$jobid));
		if($userid_job>0){
		    $this->errjson('您已申请过该职位',5);
		}
		$ResumeM=$this->MODEL('resume');
		$resume=$ResumeM->SelectExpectOne(array("uid"=>$uid,"defaults"=>1),"`id`,`uname`,`integrity`");
		if(!$resume['id']){
		    $this->errjson('您还没有简历，请先添加简历',7);
		}
		if ($this->config['user_sqintegrity']>0 && $resume['integrity']<$this->config['user_sqintegrity']){
		    $this->errjson('您的简历完成度不足'.$this->config['user_sqintegrity'].',请先完善简历',8);
		}
		$info=$JobM->GetComjobOne(array("id"=>$jobid));
		$value['eid']=$resume['id'];
		$value['job_id']=$jobid;
		$value['com_name']=$info['com_name'];
		$value['job_name']=$info['name'];
		$value['com_id']=$info['uid'];
		$value['uid']=$uid;
		$value['datetime']=time();
		$nid=$JobM->AddUseridJob($value);
		if($nid){
		    $UserinfoM->UpdateUserStatis("`sq_job`=`sq_job`+1",array("uid"=>$value['com_id']),array('usertype'=>'2'));
		    $UserinfoM->UpdateUserStatis("`sq_jobnum`=`sq_jobnum`+1",array("uid"=>$uid),array('usertype'=>'1'));
		    if($info['link_type']=='1' || $info['link_type']=='0'){
		        $ComM=$this->MODEL("company");
		        $job_link=$ComM->GetCompanyInfo(array("uid"=>$info['uid']),array("field"=>"`linkmail`,`linktel`"));
		        $info['email']=$job_link['linkmail'];
		        $info['mobile']=$job_link['linktel'];
		    }else{
		        $job_link=$JobM->GetComjoblinkOne(array("jobid"=>$jobid,"is_email"=>"1"),array("field"=>"`email`,`link_moblie`"));
		        $info['email']=$job_link['email'];
		        $info['mobile']=$job_link['link_moblie'];
		    }
		    $notice = $this->MODEL('notice');
		    if($this->config['sy_email_set']=="1"){
		        if($info['email']){
		            $contents=@file_get_contents(Url("resume",array("c"=>"sendresume","job_link"=>'1',"id"=>$resume['id'])));
		            
		            $emailData['email'] = $info['email'];
		            $emailData['subject'] = "您收到一份新的求职简历！——".$this->config['sy_webname'];
		            $emailData['content'] = $contents;
		            $notice->sendEmail($emailData);
		        }
		    }
		    if($this->config['sy_msg_isopen']=='1'){
		        if($info['mobile']){
		            $data=array('uid'=>$info['uid'],'name'=>$info['com_name'],'cuid'=>'','cname'=>'','type'=>'sqzw','jobname'=>$info['name'],'date'=>date("Y-m-d"),'moblie'=>$info['mobile']);
		            $notice->sendSMSType($data);
		        }
		    }
		    $JobM->UpdateComjob(array("`snum`=`snum`+1"),array("id"=>$jobid));
		    $this->member_log("申请职位 ".$value['job_name'], $uid, 1,6,1);
		    //推送
		    $push = $this->getPush();
		    if($push){
		        $content = mb_substr('职位：'.$info['name'].'有新简历投递', 0, 24, 'UTF-8');
		        $this->makePush($resume['uname'], $content, array('uid'=>$info['uid']), $push);
		    }
			$data['error']=1; //1-成功
		}else{
			$data['error']=2;
			$data['errmsg']='投递失败';
		}
		echo json_encode($data);die;
	}
	function fav_action(){//收藏职位
		if(!$_POST['jobid']||!$_POST['uid']){
			$data['error']=3;
			$data['errmsg']='参数不正确';
			echo json_encode($data);die;
		}
		$uid = (int)$_POST['uid'];
		$jobid = (int)$_POST['jobid'];
		$user=$this->obj->DB_select_once("member","`uid`='".$uid."'");
		if($user['usertype']!="1"){
		    $data['error']=4;
		    $data['errmsg']='您不是个人用户';
		    echo json_encode($data);die;
		}
		$ResumeM=$this->MODEL('resume');
		$rows=$ResumeM->GetFavjobOne(array("uid"=>$uid,'job_id'=>$jobid));
		if($rows['id']){
		    $data['error']=4;
		    $data['errmsg']='您已经收藏过该职位，请不要重复收藏！';
		    echo json_encode($data);die;
		}
		$JobM=$this->MODEL('job');
		$job=$JobM->GetComjobOne(array("id"=>$jobid));
		$value['job_id'] = $job['id'];
		$value['com_name'] = $job['com_name'];
		$value['job_name'] = $job['name'];
		$value['com_id'] = $job['uid'];
		$value['uid'] = $uid;
		$value['datetime'] = time();
		$nid=$JobM->AddFavJob($value);
		if($nid){
		    $UserinfoM=$this->MODEL('userinfo');
		    $UserinfoM->UpdateUserStatis("`fav_jobnum`=`fav_jobnum`+1",array("uid"=>$uid),array('usertype'=>'1'));
		    $data['error']=1;
		    $data['errmsg']='收藏成功！';
		    echo json_encode($data);die;
		}else{
		    $data['error']=2;
		    $data['errmsg']='收藏失败！';
		    echo json_encode($data);die;
		}
	}
}
?>